﻿/**
eg:
function onEnterCall(obj)
{
	alert(obj.code+":"+obj.char+":"+obj.event+":"+obj.event.srcElement.value);
}
eg1: onEnter(event,onEnterCall,'ad');
eg2: addKeyDown("objectId",onEnterCall);  or  addKeyDown("objectId",onEnterCall,"filte letters");
*/
function onEnter(evt,call,filter)
{
	//alert("aa");
	if((undefined == filter )||("" == filter)){filter="13";}
	filter=filter.toLowerCase();
	var argsObject=new Object();
	var keyCode=document.all?window.event.keyCode:evt.which;
	if(document.all){keyCode=window.event.keyCode;argsObject.event=window.event;}else{keyCode=evt.which;argsObject.event=evt;}
	var keyChar=String.fromCharCode(keyCode);
	
	keyChar=keyChar.toLowerCase();
	//alert("filter="+filter+",keyCode="+keyCode+",keyChar="+keyChar);
	argsObject.keyCode=keyCode;
	argsObject.keyChar=keyChar;
	if((keyCode == filter)||(filter == keyChar ))
	{
		call(argsObject);
	}
}
function addKeyDown(objectId,call,filter)
{
	//alert("addKeyDown");
	var obj;
	if(document.getElementById(objectId)){obj=document.getElementById(objectId);}else{return;}
	obj.onkeydown=function(event){onEnter(event,call,filter);}
}
